}

}

Constructor

A constructor is used to initialize the value of a variable at the time of its

construction. During the deployment of a smart contract, a function called

constructor gets called.

constructor() public

{

// do something…

}

Code with constructor

pragma solidity ^ 0.5.0;

contract K ia {

string message;

constructor() public {

message = "Namaste India! ";

}

function get() public view return(string memory)

{

return message;

}

function set(string memory _message) public

{

message = _message;

}

}

State variable visibility

The concerns for the state variables visibility are: One can claim the values

of the state variables from outside the contract if you make them public, A

method with the same name, which can be called a regular function (like

getter function), will be made by Solidity for each public state variable. It

will cost us less to deploy it one day to the main network, it will be much

cleaner, and our code will work the same. More gas is needed to execute the

bigger code, and the cost of running our dApp increases.